package com.legendshop.openportal.sdk.model.constants;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 取消原因
 */
@Getter
@AllArgsConstructor
public enum CancelReasonEnum {

    /**
     * 不想要了
     */
    UNWANTED("001", "不想要了"),

    /**
     * 配送时间问题
     */
    DELIVERY_TIME_ISSUE("002", "配送时间问题"),

    /**
     * 地址信息填写错误
     */
    ADDRESS_ERROR("003", "地址信息填写错误"),

    /**
     * 商品错选/多选
     */
    MISS_SELECTED_PRODUCT("004", "商品错选/多选"),

    /**
     * 商品价格问题
     */
    PRODUCT_PRICE_ISSUE("005", "商品价格问题"),

    ;

    private final String code;
    private final String message;

    /**
     * 根据code获取枚举
     *
     * @param code
     * @return
     */
    public static CancelReasonEnum fromCode(String code) {
        for (CancelReasonEnum cancelReasonEnum : CancelReasonEnum.values()) {
            if (cancelReasonEnum.getCode().equals(code)) {
                return cancelReasonEnum;
            }
        }
        return null;
    }
}